package com.feicheng.lanniao.controller.pc;


import java.time.LocalDateTime;

import com.feicheng.lanniao.anno.StaticSelectCountOfHouseLeaseInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.feicheng.lanniao.entity.House;
import com.feicheng.lanniao.entity.HouseLease;
import com.feicheng.lanniao.entity.HouseLeaseClientVo;
import com.feicheng.lanniao.result.ResultInfo;
import com.feicheng.lanniao.service.IHouseLeaseClientVoService;

/**
 * <p>
 * VIEW 前端控制器
 * </p>
 *
 * @author feichengTech
 * @since 2021-09-07
 */
@RestController
@RequestMapping("/lanniao-user/house-lease-client-vo")
public class HouseLeaseClientPcController {
	@Autowired
	private IHouseLeaseClientVoService iHouseLeaseClientVoService;

	/**
	 * 出租列表查询
	 * @param houseLeaseId 出租价格表id
	 * @param houseAreaId 面积表id
	 * @param des 描述
	 * @param provienceId 省
	 * @param cityId 市
	 * @param reignId 区
	 * @param clientId 用户id
	 * @param currentPage 当前页
	 * @param pageSize 每页多少条
	 * @return 出租列表查询集合
	 */
	@GetMapping("/page")
	public ResultInfo getList(String des,Integer provienceId,
			   Integer cityId, Integer reignId,
			   Integer clientId, Integer leaseId, Integer houseAreaId, Integer leasePriceId,
			   String tel,
			   String wxNumber,
			   String louceng,
			   String xiaoqu,
			   String pianqu,
			   String chaoxiang,
			   String zhuangxiu,
			   Integer dianti,
			   String niandai,
			   Integer roomCount,
		    @RequestParam(defaultValue = "1") Integer currentPage,
			@RequestParam(defaultValue = "10") Integer pageSize,
			String sort, Boolean dec) {
		return iHouseLeaseClientVoService.getList(des, provienceId, cityId, reignId, clientId, leaseId, houseAreaId, leasePriceId, tel, wxNumber, louceng, xiaoqu, pianqu, chaoxiang, zhuangxiu, dianti, niandai, roomCount, currentPage, pageSize,sort,dec);
	}
	/**
	 * 房出租详情查询
	 * @param leaseId 出租id
	 * @return 返回出租详情
	 */
	//@StaticSelectCountOfHouseLeaseInfo
	@GetMapping("/info")
	public ResultInfo findDetails(Integer leaseId) {

		return iHouseLeaseClientVoService.findDetails(leaseId);
	}
	/**
	 * 租房新增
	 * @param leasePrice 租金
	 * @param roomCount 户型
	 * @param area 面积
	 * @param provienceId 省ID
	 * @param cityId 市ID
	 * @param reignId 区ID
	 * @param imgUrl 封面地址
	 * @param clientId 用户ID
	 * @param pianqu 片区
	 * @param xiaoqu 小区
	 * @param zhuangxiu 装修
	 * @param chaoxiang 朝向
	 * @param dianti 有误电梯
	 * @param louceng 楼层
	 * @param tel 发布电话
	 * @param wxNumber 微信号
	 * @param niandai 房屋年代
	 * @return
	 */
	@PostMapping("/info")
	public ResultInfo addHouseLeaseClient(
			Integer leasePrice,   Integer roomCount,
			Integer area, Integer provienceId, Integer cityId, Integer reignId, String imgUrl,
			 Integer clientId,
			String pianqu,
			String xiaoqu,
			String zhuangxiu,
			String chaoxiang,
			Integer dianti,
			String louceng,
			String tel,
			String wxNumber,
			String niandai
	) {
		return iHouseLeaseClientVoService.addHouseLeaseClient(
				leasePrice,roomCount,area,
				provienceId, cityId,reignId,imgUrl,
				clientId,
				pianqu,
				xiaoqu,
				zhuangxiu,
				chaoxiang,
				dianti,
				louceng,
				tel,
				wxNumber,
				niandai
				);
	}
	/**
	 * 租房更新
	 Integer provienceId, 省
	 Integer cityId, 市
	 Integer reignId, 区
	 String pianqu, 片区
	 String xiaoqu, 小区
	 Integer roomCount, 几室
	 String chaoxiang, 朝向
	 Integer dianti, 电梯
	 String zhuangxiu, 装修
	 String niandai, 年代
	 Integer area, 面积
	 String imgUrl, 图片
	 Integer leaseId, 发布id
	 Integer leasePrice, 租房价格
	 String louceng, 楼层
	 String tel, 电话
	 String wxNumber 微信
	 */
	@PutMapping("/info")
	public ResultInfo updateHouseLeaseClient(
			Integer provienceId,
			Integer cityId,
			Integer reignId,
			String pianqu,
			String xiaoqu,
			Integer roomCount,
			String chaoxiang,
			Integer dianti,
			String zhuangxiu,
			String niandai,
			Integer area,
			String imgUrl,
			Integer leaseId,
			Integer leasePrice,
			String louceng,
			String tel,
			String wxNumber
	) {
		return iHouseLeaseClientVoService.updateHouseLeaseV2(provienceId,
				 cityId,
				 reignId,
				 pianqu,
				 xiaoqu,
				 roomCount,
				 chaoxiang,
				 dianti,
				 zhuangxiu,
				 niandai,
				 area,
				 imgUrl,
				 leaseId,
				 leasePrice,
				 louceng,
				 tel,
				 wxNumber);
		//return iHouseLeaseClientVoService.updateHouseLease(houseLeaseClientVo);
	}

	/**
	 * 租房删除
	 * @param houseLease 出租房对象
	 * @return 布尔值 true-成功 false-失败
	 */
	@DeleteMapping("/info")
	public ResultInfo deleteHouseLeaseClient(HouseLease houseLease) {
		return iHouseLeaseClientVoService.deleteHouseLeaseClient(houseLease);
	}
}

